You can specify it when you create a new rmarkdown document.
You can also specify it later in the YAML header.
---
title: "rmarkdown_pdf_docx"
author: "Sebastien Renaut"
date: '2018-09-06'
output: word_document
---
Then, it’s just a matter of kniting the document!
Little documentation, few options & configurations are possible. (This is not the course of events that should be promoted, as it moves away from an open source environment).
You need a extra step to go from LaTeX (.tex) format to a .pdf. This is handled by the pdflatex function in R.
LaTeX software is a high-quality typesetting system.
It is the de facto standard for the communication and publication of scientific documents.
LaTeX is available as free software.
Latex software is available here.
If interested, follow this discussion: Why LaTeX is such a bloated system?
So…TinyTeX is a custom LaTeX distribution based on TeX Live that is small in size (~150MB) but functions well in most cases, especially for R users .
tinytex R package is a wrapper function that installs TinyTeX.
tinytex R package from the console.install.packages(“tinytex”)
library(tinytex)
It takes a few minutes to download and compile tinytex (~150MB)
install_tinytex()
-–
title: “rmarkdown_pdf_docx”
author: “Sebastien Renaut”
date: ‘2018-09-06’
output: pdf_document
-–
-–
output
pdf_document:
keep_tex: true
fig_caption: true
latex_engine: pdflatex
title: “This is my first Rmarkdown manuscript”
date: February 07, 2019
geometry: margin=1in
fontfamily: mathpazo
fontsize: 11pt
spacing: double
csl: ../reference_material/peerj.csl
bibliography: ../reference_material/reference.bib
-–
Note the indentation in the .Rmd document.
Note the bibliography file and csl file for formatting references.
rticles (10min.)This is a nice package to format articles according to the specification of a journal.
But first, you need to install it in the R console install.packages("rticles").
```{r rticles, include=T}
#install.packages(“rticles”)
library(rticles)
```
You can build your own template if you know Latex…
There are many templates available on the web that you can use.
Here is one I like for manuscripts (Thanks svmiller!):
Here is one I like for CVs:
Simply download it and add it to the YAML header like this: template: ../reference_material/svm-latex-ms.tex
-– output:
pdf_document:
keep_tex: true
fig_caption: true
latex_engine: pdflatex
template: ../reference_material/svm-latex-ms.tex
title: "This is my first Rmarkdown manuscript
-–
Remember this:
So you can generate your .tex file, upload it to a github repo and Overleaf will connect to it. Others can then collaborate and modify the .tex file.
Let’s take a quick look at overleaf. Once you have an overleaf account, you can connect it to a github repository. You can then pull/push from overleaf to github, allowing others to modify your .tex file.
Radix offers a better look for publishing blog, webpages, adapted to mobile devices.
radix```{r radix, echo = T}
install.packages(“radix”)
```
-–
title: “Rmarkdown: radix”
author: “Sebastien Renaut”
output: radix::radix_article
-–
radix options, such as in this example below (full width figures):```{r radix_example, echo = F, layout=‘l-screen-inset’}
library(leaflet)
leaflet() %>%
addTiles() %>%
addMarkers(lng=174.768, lat=-36.852,popup=“The birthplace of R”)
```